package edu.nus.mtech.sem1.ca.auth;

import java.util.List;

import edu.nus.mtech.sem1.ca.data.Database;
import edu.nus.mtech.sem1.ca.data.DatabaseLoader;

/**
 * Don't think anybody is using this now. Fancy method though. Can use it later.
 *
 */
public class AccessControlManager {
	
	private static Database database;
	
	static{
		database=DatabaseLoader.getInstance().getDatabase();
	}

	public static boolean isUserAuthorized(User user, String accessViewClientComplaints) {
		
		if (database!=null && user!=null){
			List<String> accessesForUserRole = database.getAccessesForUserRole(user.getUserRole());
			if (accessesForUserRole.contains(accessViewClientComplaints)){
				return true;
			}
		}
		else{
			System.err.println("Error initializing database.");//Can't happen coz of static initialization. Test case proved it
			
		}
		return false;
	}
	
	

}
